package com.thz.houserental.infrastructure.exception;

import cn.hutool.core.util.StrUtil;
import lombok.Data;
import org.springframework.http.HttpStatus;

@Data
public class NotFoundException extends HttpException {
    public NotFoundException() {
        this.code = HttpStatus.NOT_FOUND.value();
        this.message = HttpStatus.NOT_FOUND.getReasonPhrase();
    }
    
    public NotFoundException(int code) {
        this.code = code;
        String codeMessage = ExceptionCodeConfiguration.getMessage(code);
        if(StrUtil.isNotEmpty(codeMessage)) {
            this.message = codeMessage;
        } else {
            this.message = HttpStatus.NOT_FOUND.getReasonPhrase();
        }
    }
}